import junit.framework.TestCase;
import org.junit.Test;

public class ComplexTest extends TestCase {
    Complex a = new Complex(2.0,4.0);
    Complex b = new Complex(0.0,-0.0);
    Complex c = new Complex(-4.0,0.0);
    @Test
    public void testgetRealpart(){
        assertEquals(2.0,a.getRealPart());
        assertEquals(0.0,b.getRealPart());
        assertEquals(-4.0,c.getRealPart());
    }
    @Test
    public void testgetImagePart(){
        assertEquals(4.0,a.getImagePart());
        assertEquals(-0.0,b.getImagePart());
        assertEquals(0.0,c.getImagePart());
    }
    @Test
    public void testComplexAdd(){
        String q = a.ComplexAdd(b).toString();
        String w = b.ComplexAdd(c).toString();
        String e = c.ComplexAdd(a).toString();
        assertEquals("2.0+4.0i",q);
        assertEquals("-4.0",w);
        assertEquals("-2.0+4.0i",e);
    }
    @Test
    public void testComplexSub(){
        String r = a.ComplexSub(b).toString();
        String t = b.ComplexSub(c).toString();
        String y = c.ComplexSub(a).toString();
        assertEquals("2.0+4.0i",r);
        assertEquals("4.0",t);
        assertEquals("-8.0i",y);
    }
    @Test
    public void testComplexMulti(){
        String u = a.ComplexMulti(b).toString();
        String i = b.ComplexMulti(c).toString();
        String o = c.ComplexMulti(a).toString();
        assertEquals("0",u);
        assertEquals("0",i);
        assertEquals("-8.0",o);
    }
    @Test
    public void testComplexDiv(){
        String p = c.ComplexDiv(a).toString();
        assertEquals("-2.0i",p);
    }
    @Test
    public void testtoString(){
        assertEquals("2.0+4.0i",a.toString());
        assertEquals("0",b.toString());
        assertEquals("-4.0",c.toString());
    }
}